<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - /home/jkbs/src/zpr/imageeditor/tests/testCommand.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../../index.html">directory</a> - <a href="index.html">home/jkbs/src/zpr/imageeditor/tests</a> - testCommand.cpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">132</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">132</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : #define BOOST_TEST_MAIN
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : #ifndef _MSC_VER
<span class="lineNum">       4 </span>                : 
<span class="lineNum">       5 </span>                : // Wyłączenie dynamicznego linkowania dla Windows
<span class="lineNum">       6 </span>                : #define BOOST_TEST_DYN_LINK
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                : #else
<span class="lineNum">       9 </span>                : 
<span class="lineNum">      10 </span>                : // Obejście problemów z deklaracjami typów w bibliotece jpeg pod
<span class="lineNum">      11 </span>                : // Windows
<span class="lineNum">      12 </span>                : #define XMD_H
<span class="lineNum">      13 </span>                : 
<span class="lineNum">      14 </span>                : #endif
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : #include &lt;boost/test/included/unit_test.hpp&gt;
<span class="lineNum">      17 </span>                : #include &lt;boost/filesystem.hpp&gt;
<span class="lineNum">      18 </span>                : 
<span class="lineNum">      19 </span>                : #include &lt;boost/gil/gil_all.hpp&gt;
<span class="lineNum">      20 </span>                : #include &lt;boost/gil/extension/io/jpeg_io.hpp&gt;
<span class="lineNum">      21 </span>                : 
<span class="lineNum">      22 </span>                : #include &quot;../ged/Editor.hpp&quot;
<span class="lineNum">      23 </span>                : #include &quot;../ged/Command.hpp&quot;
<span class="lineNum">      24 </span>                : #include &quot;../ged/Observer.hpp&quot;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : using namespace ged;
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span><span class="lineCov">              1 : BOOST_AUTO_TEST_SUITE( test_Command )</span>
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span><span class="lineCov">              1 : static const boost::filesystem::path image_path(&quot;tests/images/boost.jpg&quot;);</span>
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span>                : //FlipUpDownCommand
<span class="lineNum">      33 </span><span class="lineCov">              3 : BOOST_AUTO_TEST_CASE( test_case_1 )</span>
<span class="lineNum">      34 </span>                : {
<span class="lineNum">      35 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">      36 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">      39 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">      40 </span><span class="lineCov">              1 :         PCommand f1(new FlipUpDownCommand);</span>
<span class="lineNum">      41 </span><span class="lineCov">              1 :         editor-&gt;execute(f1);</span>
<span class="lineNum">      42 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">      45 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      46 </span><span class="lineCov">              1 :         a-&gt;setView(flipped_up_down_view (a-&gt;getView()));</span>
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">      51 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      52 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">      53 </span>                : 
<span class="lineNum">      54 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;selectLayer(1);</span>
<span class="lineNum">      55 </span><span class="lineCov">              1 :         PImageLayer d = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      56 </span><span class="lineCov">              1 :         d-&gt;setView(flipped_up_down_view (d-&gt;getView()));</span>
<span class="lineNum">      57 </span><span class="lineCov">              1 :         BOOST_CHECK(c-&gt;getView() == d-&gt;getView());</span>
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">      60 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">      61 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      62 </span>                : //FlipLeftRightCommand
<span class="lineNum">      63 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_CASE( test_case_2 )</span>
<span class="lineNum">      64 </span>                : {
<span class="lineNum">      65 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">      66 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">      67 </span>                : 
<span class="lineNum">      68 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">      69 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">      70 </span><span class="lineCov">              1 :         PCommand f2(new FlipLeftRightCommand);</span>
<span class="lineNum">      71 </span><span class="lineCov">              1 :         editor-&gt;execute(f2);</span>
<span class="lineNum">      72 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      73 </span>                : 
<span class="lineNum">      74 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">      75 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      76 </span><span class="lineCov">              1 :         a-&gt;setView(flipped_left_right_view (a-&gt;getView()));</span>
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">      81 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      82 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;selectLayer(1);</span>
<span class="lineNum">      85 </span><span class="lineCov">              1 :         PImageLayer d = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">      86 </span><span class="lineCov">              1 :         d-&gt;setView(flipped_left_right_view (d-&gt;getView()));</span>
<span class="lineNum">      87 </span><span class="lineCov">              1 :         BOOST_CHECK(c-&gt;getView() == d-&gt;getView());</span>
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">      90 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">      91 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">      92 </span>                : //SubimageCommand
<span class="lineNum">      93 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_CASE( test_case_3 )</span>
<span class="lineNum">      94 </span>                : {
<span class="lineNum">      95 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">      96 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">      97 </span>                : 
<span class="lineNum">      98 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">      99 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     100 </span>                :         //rozmiar orginalnego obrazka
<span class="lineNum">     101 </span><span class="lineCov">              1 :         Image::view_type image_view =editor-&gt;getImage()-&gt;getView();</span>
<span class="lineNum">     102 </span>                : 
<span class="lineNum">     103 </span><span class="lineCov">              1 :         PCommand s1(new SubimageCommand(0,0,50,50));</span>
<span class="lineNum">     104 </span><span class="lineCov">              1 :         editor-&gt;execute(s1);</span>
<span class="lineNum">     105 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     106 </span>                : 
<span class="lineNum">     107 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     108 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     109 </span><span class="lineCov">              1 :         a-&gt;setView(subimage_view(a-&gt;getView(),0, 0, 50, 50 ) );</span>
<span class="lineNum">     110 </span>                : 
<span class="lineNum">     111 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">     114 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     115 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;selectLayer(1);</span>
<span class="lineNum">     118 </span><span class="lineCov">              1 :         PImageLayer d = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     119 </span><span class="lineCov">              1 :         d-&gt;setView(subimage_view(d-&gt;getView(),0,0,image_view.width(),image_view.height()));</span>
<span class="lineNum">     120 </span><span class="lineCov">              1 :         BOOST_CHECK(c-&gt;getView() == d-&gt;getView());</span>
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     123 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     124 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">     125 </span>                : //SubsampleCommand
<span class="lineNum">     126 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_CASE( test_case_4 )</span>
<span class="lineNum">     127 </span>                : {
<span class="lineNum">     128 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">     129 </span>                : 
<span class="lineNum">     130 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">     131 </span>                : 
<span class="lineNum">     132 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">     133 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span><span class="lineCov">              1 :         PCommand s2(new SubsampleCommand(2,3));</span>
<span class="lineNum">     136 </span><span class="lineCov">              1 :         editor-&gt;execute(s2);</span>
<span class="lineNum">     137 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     138 </span>                : 
<span class="lineNum">     139 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     140 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     141 </span><span class="lineCov">              1 :         a-&gt;setView(subsampled_view(a-&gt;getView(),2,3));</span>
<span class="lineNum">     142 </span>                : 
<span class="lineNum">     143 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">     146 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     147 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     150 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     151 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">     152 </span>                : //RotateCwCommand
<span class="lineNum">     153 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_CASE( test_case_5 )</span>
<span class="lineNum">     154 </span>                : {
<span class="lineNum">     155 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">     156 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">     157 </span>                : 
<span class="lineNum">     158 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">     159 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     160 </span><span class="lineCov">              1 :         PCommand r1(new RotateCwCommand);</span>
<span class="lineNum">     161 </span><span class="lineCov">              1 :         editor-&gt;execute(r1);</span>
<span class="lineNum">     162 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     163 </span>                : 
<span class="lineNum">     164 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     165 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     166 </span><span class="lineCov">              1 :         a-&gt;setView(rotated90cw_view (a-&gt;getView()));</span>
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">     169 </span>                : 
<span class="lineNum">     170 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">     171 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     172 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">     173 </span>                : 
<span class="lineNum">     174 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;selectLayer(1);</span>
<span class="lineNum">     175 </span><span class="lineCov">              1 :         PImageLayer d = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     176 </span><span class="lineCov">              1 :         d-&gt;setView(rotated90ccw_view(d-&gt;getView()));</span>
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span><span class="lineCov">              1 :         BOOST_CHECK(c-&gt;getView() == d-&gt;getView());</span>
<span class="lineNum">     179 </span>                : 
<span class="lineNum">     180 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     181 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     182 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">     183 </span>                : //RotateCcwCommand
<span class="lineNum">     184 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_CASE( test_case_6 )</span>
<span class="lineNum">     185 </span>                : {
<span class="lineNum">     186 </span><span class="lineCov">              1 :         Editor *editor = Editor::getInstance();</span>
<span class="lineNum">     187 </span><span class="lineCov">              1 :         PGILImage p1_image(new GILImage);</span>
<span class="lineNum">     188 </span>                : 
<span class="lineNum">     189 </span><span class="lineCov">              2 :         jpeg_read_image(image_path.file_string(), *p1_image);</span>
<span class="lineNum">     190 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     191 </span><span class="lineCov">              1 :         PCommand r2(new RotateCcwCommand);</span>
<span class="lineNum">     192 </span><span class="lineCov">              1 :         editor-&gt;execute(r2);</span>
<span class="lineNum">     193 </span><span class="lineCov">              1 :         PImageLayer b = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     194 </span>                : 
<span class="lineNum">     195 </span><span class="lineCov">              1 :         editor-&gt;addImageLayer(p1_image);</span>
<span class="lineNum">     196 </span><span class="lineCov">              1 :         PImageLayer a = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     197 </span><span class="lineCov">              1 :         a-&gt;setView(rotated90ccw_view (a-&gt;getView()));</span>
<span class="lineNum">     198 </span>                : 
<span class="lineNum">     199 </span><span class="lineCov">              1 :         BOOST_CHECK(b-&gt;getView() == a-&gt;getView());</span>
<span class="lineNum">     200 </span>                : 
<span class="lineNum">     201 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;selectLayer(0);</span>
<span class="lineNum">     202 </span><span class="lineCov">              1 :         PImageLayer c = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     203 </span><span class="lineCov">              1 :         editor-&gt;unExecute();</span>
<span class="lineNum">     204 </span>                : 
<span class="lineNum">     205 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;selectLayer(1);</span>
<span class="lineNum">     206 </span><span class="lineCov">              1 :         PImageLayer d = editor-&gt;getImage()-&gt;getLayer();</span>
<span class="lineNum">     207 </span><span class="lineCov">              1 :         d-&gt;setView(rotated90cw_view(d-&gt;getView()));</span>
<span class="lineNum">     208 </span>                : 
<span class="lineNum">     209 </span><span class="lineCov">              1 :         BOOST_CHECK(c-&gt;getView() == d-&gt;getView());</span>
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span><span class="lineCov">              2 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     212 </span><span class="lineCov">              1 :         editor-&gt;getImage()-&gt;deleteLayer();</span>
<span class="lineNum">     213 </span><span class="lineCov">              1 : }</span>
<span class="lineNum">     214 </span>                : 
<span class="lineNum">     215 </span><span class="lineCov">              4 : BOOST_AUTO_TEST_SUITE_END()</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
